package com.holyant.goods.enums;

import java.util.Arrays;
import java.util.List;

public enum QuoteSalesChannel {
    C2P(10, "C2P"),
    POP(20, "POP"),
    B2B_CN(30, "B2B-CN"),
    B2B_HK(31, "B2B-HK"),
    B2B_MO(32, "B2B-MO"),
    KA(50, "KA"),
    WM(60, "WM"),
    WM_C(61, "WM-C"),
    WM_B(62, "WM-B"),
    WM_O2O(63, "WM-O2O"),
    O2O(70, "O2O");

    private final Integer code;
    private final String name;

    QuoteSalesChannel(Integer code, String name) {
        this.code = code;
        this.name = name;
    }

    public Integer getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    public static String getNameByCode(Integer code) {
        for (QuoteSalesChannel quoteSalesChannel : QuoteSalesChannel.values()) {
            if (quoteSalesChannel.getCode().equals(code)) {
                return quoteSalesChannel.getName();
            }
        }
        return null;
    }

    public static Integer getCodeByName(String name) {
        for (QuoteSalesChannel quoteSalesChannel : QuoteSalesChannel.values()) {
            if (quoteSalesChannel.getName().equals(name)) {
                return quoteSalesChannel.getCode();
            }
        }
        return null;
    }


    public static boolean hasSubmitCheck(Integer code){
        List<Integer> asList = Arrays.asList(B2B_CN.getCode(), B2B_HK.getCode(), B2B_MO.getCode(),KA.getCode(),WM_B.getCode());
        return asList.contains(code);
    }
}
